package cycle.retain;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import jcolibri.cbrcore.CBRCase;
import jcolibri.cbrcore.CBRCaseBase;
import cycle.RentDescription;
import cycle.RentSolution;

public class RetainConfig {
	
	Collection<CBRCase> selectedcases;
	CBRCaseBase caseBase;
	List<CBRCase> cases, casesToRetain;
	int casebasesize;
	
	public RetainConfig(Collection<CBRCase> _selectedcases, CBRCaseBase _caseBase) {
		selectedcases = _selectedcases;
		cases = new ArrayList<CBRCase>(selectedcases);
		casesToRetain = new ArrayList<CBRCase>();
		caseBase = _caseBase;
		casebasesize = caseBase.getCases().size();
	}
	
	public void addCaseToRetain(int _caseNumber) {
		CBRCase _case = cases.get(_caseNumber);
		cases.remove(_case);
		
		RentDescription rd = (RentDescription) _case.getDescription();
		rd.setCaseId("Case "+(++casebasesize));
		
		casesToRetain.add(_case);
	}
	
	public void learn() {
		if(casebasesize > 0)
			caseBase.learnCases(casesToRetain);
	}
	
	public String getNomeEdificio(int _case) {
		RentSolution sol = getCaseSolution(_case);
		return sol.getNomeEdificio();
	}
	
	public double getAluguelMensal(int _case) {
		RentSolution sol = getCaseSolution(_case);
		return sol.getAluguelMensal();
	}
	
	public String getBairro(int _case) {
		RentDescription desc = getCaseDescription(_case);
		return desc.getBairro();
	}
	
	public String getRegiao(int _case) {
		RentDescription desc  = getCaseDescription(_case);
		return desc.getRegiao();
	}
	
	public double getAreaPrivativa(int _case) {
		RentDescription desc  = getCaseDescription(_case);
		return desc.getAreaPrivativa();
	}
	
	public int getVagasGaragem(int _case) {
		RentDescription desc  = getCaseDescription(_case);
		return desc.getVagasGaragem();
	}
	
	public int getQuartos(int _case) {
		RentDescription desc  = getCaseDescription(_case);
		return desc.getQuartos();
	}

	public int getSuites(int _case) {
		RentDescription desc  = getCaseDescription(_case);
		return desc.getSuites();
	}
	
	public CBRCase getCase(int i) {
		CBRCase _case = cases.get(i);
		return _case;
	}
	
	public RentDescription getCaseDescription(int _caseNumber) {
		CBRCase _case = getCase(_caseNumber);
		return (RentDescription) _case.getDescription();
	}
	
	public RentSolution getCaseSolution(int _caseNumber) {
		CBRCase _case = getCase(_caseNumber);
		return (RentSolution) _case.getSolution();
	}
	
}